package com.atguigu.juc.chap10;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CompletableFutureDemo01 {

    public static void main(String[] args) {

        // 1、创建线程池对象
        ExecutorService threadPool = Executors.newFixedThreadPool(5);

        // 2、创建 Runnable 类型对象封装任务内容
        Runnable runnable = ()->{
            System.out.println(Thread.currentThread().getName() + " is working");
        };

        // 3、将异步任务提交到自己指定的线程池
        CompletableFuture.runAsync(runnable, threadPool);

        System.out.println("main");
        
        // 4、关闭线程池
        threadPool.shutdown();
    }
}